package c.e.b.h.e.k;

import android.content.Context;
import c.b.a.a.a;
import c.e.b.h.e.m.n;
import c.e.b.h.e.m.p;
import c.e.b.h.e.m.q;
import c.e.b.h.e.m.v;
import c.e.b.h.e.m.v.d.d.a.b.b;
import c.e.b.h.e.m.w;
import c.e.b.h.e.t.d;
import c.e.b.h.e.t.e;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

/* compiled from: CrashlyticsReportDataCapture */
public class i0 {
    public static final String e = String.format(Locale.US, "Crashlytics Android SDK/%s", new Object[]{"17.2.2"});
    public static final Map<String, Integer> f;
    public final Context a;
    public final q0 b;
    public final b c;
    public final d d;

    static {
        HashMap hashMap = new HashMap();
        f = hashMap;
        hashMap.put("armeabi", Integer.valueOf(5));
        hashMap.put("armeabi-v7a", Integer.valueOf(6));
        hashMap.put("arm64-v8a", Integer.valueOf(9));
        hashMap.put("x86", Integer.valueOf(0));
        hashMap.put("x86_64", Integer.valueOf(1));
    }

    public i0(Context context, q0 q0Var, b bVar, d dVar) {
        this.a = context;
        this.b = q0Var;
        this.c = bVar;
        this.d = dVar;
    }

    public final b a(e eVar, int i, int i2, int i3) {
        String str = eVar.b;
        String str2 = eVar.a;
        StackTraceElement[] stackTraceElementArr = eVar.c;
        int i4 = 0;
        if (stackTraceElementArr == null) {
            stackTraceElementArr = new StackTraceElement[0];
        }
        eVar = eVar.d;
        if (i3 >= i2) {
            e eVar2 = eVar;
            while (eVar2 != null) {
                eVar2 = eVar2.d;
                i4++;
            }
        }
        b bVar = null;
        Objects.requireNonNull(str, "Null type");
        w wVar = new w(b(stackTraceElementArr, i));
        Integer valueOf = Integer.valueOf(i4);
        if (eVar != null && i4 == 0) {
            bVar = a(eVar, i, i2, i3 + 1);
        }
        String str3 = valueOf == null ? " overflowCount" : "";
        if (str3.isEmpty()) {
            return new n(str, str2, wVar, bVar, valueOf.intValue(), null);
        }
        throw new IllegalStateException(a.D("Missing required properties:", str3));
    }

    public final w<v.d.d.a.b.d.a> b(StackTraceElement[] stackTraceElementArr, int i) {
        ArrayList arrayList = new ArrayList();
        for (StackTraceElement stackTraceElement : stackTraceElementArr) {
            q.b bVar = new q.b();
            bVar.e = Integer.valueOf(i);
            long j = 0;
            long max = stackTraceElement.isNativeMethod() ? Math.max((long) stackTraceElement.getLineNumber(), 0) : 0;
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(stackTraceElement.getClassName());
            stringBuilder.append(".");
            stringBuilder.append(stackTraceElement.getMethodName());
            String stringBuilder2 = stringBuilder.toString();
            String fileName = stackTraceElement.getFileName();
            if (!stackTraceElement.isNativeMethod() && stackTraceElement.getLineNumber() > 0) {
                j = (long) stackTraceElement.getLineNumber();
            }
            bVar.a = Long.valueOf(max);
            Objects.requireNonNull(stringBuilder2, "Null symbol");
            bVar.b = stringBuilder2;
            bVar.c = fileName;
            bVar.d = Long.valueOf(j);
            arrayList.add(bVar.a());
        }
        return new w(arrayList);
    }

    public final v.d.d.a.b.d c(Thread thread, StackTraceElement[] stackTraceElementArr, int i) {
        String name = thread.getName();
        Objects.requireNonNull(name, "Null name");
        Integer valueOf = Integer.valueOf(i);
        w wVar = new w(b(stackTraceElementArr, i));
        String str = valueOf == null ? " importance" : "";
        if (str.isEmpty()) {
            return new p(name, valueOf.intValue(), wVar, null);
        }
        throw new IllegalStateException(a.D("Missing required properties:", str));
    }
}
